const App = getApp();
Page({
    data: {
        imgUrl:App.globalData.imgUrl,
        isLoading: true,
        reLoading: false,
        generate_id: 0,
        list: [],
    },
    onLoad: function (options) {
        let _this = this;
        _this.setData({
            generate_id: options.generate_id
        })
        _this.getGenerateLog();
    },

    // 获取赋能访问记录
    getGenerateLog(page = 1) {
        let _this = this;
        App._get('Generate/getGenerateLog', {
            generate_id: _this.data.generate_id,
            page,
        }, res => {
            _this.setData({
                list: _this.data.list.concat(res.data.list.data),
                current_page: res.data.list.current_page,
                last_page: res.data.list.last_page,
                total: res.data.list.total,
            })
        }, false, () => {
            _this.setData({
                isLoading: false,
                reLoading: false,
            })
        });
    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {
        this.ajaxloading = this.selectComponent("#ajax_loading");
        if (this.data.current_page >= this.data.last_page) {
            this.ajaxloading.AjaxLoading(true);
            this.ajaxloading.AjaxNoresult(false);
            return false;
        }
        this.getGenerateLog(this.data.current_page + 1);
        this.ajaxloading.AjaxLoading(false);
    },

});
